from rest_framework.viewsets import ModelViewSet
from orders.models import OrderInfo
from meiduo_mall_admin.my_paginate import MyPageNumberPagination
from . import order_serializers

class OrderViewSet(ModelViewSet):
    serializer_class = order_serializers.OrderViewSrializers
    # queryset = OrderInfo.objects.all()
    pagination_class = MyPageNumberPagination


    def get_queryset(self):
        # 获取关键字
        keyword = self.request.query_params.get("keyword", "")

        # 返回
        return OrderInfo.objects.filter(order_id__contains=keyword).all()
